<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- $Id$ -->
<xsl:stylesheet version="1.1"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                exclude-result-prefixes="fo">
  <xsl:output method="xml" version="1.0" omit-xml-declaration="no" indent="yes"/>
  <xsl:param name="versionParam" select="'1.0'"/> 
  <!-- ========================= -->
  <!-- root element: projectteam -->
  <!-- ========================= -->
  <xsl:template match="itinerary-info">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
      <fo:layout-master-set>
        <fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="1cm" margin-right="1cm">

          <fo:region-body />
          <fo:region-after />

        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="simpleA4">
        <fo:static-content flow-name="xsl-region-after">
          <fo:block-container height="100%" display-align="center">
            <fo:block font-size="0.8em" text-align="center" color="green" font-family="sans-serif,仿宋">
                <xsl:value-of select="companySign"/>
            </fo:block>
          </fo:block-container>
        </fo:static-content>
        <fo:flow flow-name="xsl-region-body">
          <fo:block font-size="20pt" font-family="sans-serif,仿宋" font-weight="bold" space-after="10mm" text-align="center">
              行程单
          </fo:block>

          <fo:block font-size="16pt" font-family="sans-serif,仿宋" font-weight="bold" space-before="3mm" space-after="3mm">
            航班详情
          </fo:block>
          <fo:block>
            <fo:table table-layout="fixed" width="100%" font-family="sans-serif,仿宋" border-spacing="5px" padding="1px">
              <fo:table-column column-width="2cm" />
              <fo:table-column column-width="proportional-column-width(1)" />
              <fo:table-column column-width="proportional-column-width(1)" />
              <fo:table-column column-width="2cm" />
              <fo:table-column column-width="3cm" />
              <fo:table-header background="blue">
                <fo:table-row background-color="gray" color="white" text-align="center"  display-align="center">
                    <fo:table-cell display-align="center">
                        <fo:block font-weight="bold">日期</fo:block>
                    </fo:table-cell>
                  <fo:table-cell>
                    <fo:block font-weight="bold">始发</fo:block>
                    <fo:block font-weight="bold">时间</fo:block>
                    <fo:block font-weight="bold">航站楼</fo:block>
                  </fo:table-cell>
                  <fo:table-cell>
                    <fo:block font-weight="bold">抵达</fo:block>
                      <fo:block font-weight="bold">时间</fo:block>
                      <fo:block font-weight="bold">航站楼</fo:block>
                  </fo:table-cell>
                  <fo:table-cell display-align="center">
                    <fo:block font-weight="bold">航班号</fo:block>
                  </fo:table-cell>
                  <fo:table-cell display-align="center">
                    <fo:block font-weight="bold">舱位</fo:block>
                  </fo:table-cell>
                </fo:table-row>
              </fo:table-header>
              <fo:table-body>
                <xsl:apply-templates select="flights"/>
              </fo:table-body>
            </fo:table>
          </fo:block>
          <fo:block font-size="16pt" font-family="sans-serif,仿宋" font-weight="bold" space-before="5mm" space-after="3mm">
            乘客
          </fo:block>
          <fo:block>
            <fo:table table-layout="fixed" width="100%" border-collapse="collapse"  font-family="sans-serif,仿宋" border="5px">
              <fo:table-column column-width="3cm" />
              <fo:table-column column-width="3cm" />
              <fo:table-column />
              <fo:table-column />
              <fo:table-header>
                <fo:table-row  background-color="gray" color="white" text-align="center"  display-align="center" border-bottom="5px">
                  <fo:table-cell>
                    <fo:block font-weight="bold">姓名</fo:block>
                  </fo:table-cell>
                  <fo:table-cell>
                    <fo:block font-weight="bold">证件类型</fo:block>
                  </fo:table-cell>
                  <fo:table-cell>
                    <fo:block font-weight="bold">证件号</fo:block>
                  </fo:table-cell>
                  <fo:table-cell>
                    <fo:block font-weight="bold">票号</fo:block>
                  </fo:table-cell>
                </fo:table-row>
              </fo:table-header>
              <fo:table-body>
                <xsl:apply-templates select="passengers"/>
              </fo:table-body>
            </fo:table>
          </fo:block>

        </fo:flow>

      </fo:page-sequence>
    </fo:root>
  </xsl:template>
  <!-- ========================= -->
  <!-- child element: flights     -->
  <!-- ========================= -->
  <xsl:template match="flights">
    <fo:table-row space-after="3mm" border-bottom="1px solid gray" font-size="10pt">
      <xsl:if test="function = 'lead'">
        <xsl:attribute name="font-weight">bold</xsl:attribute>
      </xsl:if>
        <fo:table-cell text-align="center">
            <fo:block>
                <xsl:value-of select="ddate"/>
            </fo:block>
        </fo:table-cell>

      <fo:table-cell text-align="center">
        <fo:block font-family="仿宋">
            <xsl:value-of select="dport"/>-<xsl:value-of select="dportNameCn"/>-<xsl:value-of select="dportNameEn"/>
        </fo:block>
          <fo:block font-family="sans-serif">
              <xsl:value-of select="dtime"/>
          </fo:block>
        <fo:block font-family="sans-serif,仿宋">
          航站楼: <xsl:value-of select="dterm"/>
        </fo:block>
      </fo:table-cell>

      <fo:table-cell text-align="center">
        <fo:block font-family="仿宋">
            <xsl:value-of select="aport"/>-<xsl:value-of select="aportNameCn"/>-<xsl:value-of select="aportNameEn"/>
        </fo:block>
          <fo:block font-family="sans-serif,仿宋">
              <xsl:value-of select="atime"/>
          </fo:block>
        <fo:block font-family="sans-serif,仿宋">
          航站楼: <xsl:value-of select="aterm"/>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell text-align="center">
        <fo:block>
          <xsl:value-of select="flightNo"/>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell text-align="center">
        <fo:block>
          <xsl:value-of select="subclass"/>
        </fo:block>
      </fo:table-cell>
    </fo:table-row>
  </xsl:template>
  <!-- ========================= -->
  <!-- child element: passengers     -->
  <!-- ========================= -->
  <xsl:template match="passengers">
    <fo:table-row  border-bottom="1px solid gray"  font-size="10pt">
      <xsl:if test="function = 'lead'">
        <xsl:attribute name="font-weight">bold</xsl:attribute>
      </xsl:if>
      <fo:table-cell text-align="center">
        <fo:block font-family="sans-serif,仿宋">
          <xsl:value-of select="name"/>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell text-align="center">
        <fo:block>
          <xsl:value-of select="idTypeDesc"/>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell text-align="center">
        <fo:block>
          <xsl:value-of select="idNo"/>
        </fo:block>
      </fo:table-cell>
      <fo:table-cell text-align="center">
        <fo:block>
          <xsl:value-of select="ticketNo"/>
        </fo:block>
      </fo:table-cell>
    </fo:table-row>
  </xsl:template>
</xsl:stylesheet>
